ServerOptions: different input & output device names only works on osx
[supercollider.git] / examples / GUI examples / Nick's LetterGimmick.scd
blob6123ac2977561d116b04d2dd0c3864f207a14e75
3 var linetext, drawletter;
4 var w, h = 800, v = 60, seed = Date.seed, run = true;
5 var time, name, sourcestring;
6 var yellowness, penwidth, pen;
8 //name=[\s,\u,\p,\e,\r,\c,\o,\l,\l,\i,\d,\e,\r];
10 //sourcestring= "any lower case text";
12 sourcestring= "welcome to supercollider";
14 name=Array.fill(sourcestring.size,{arg i; sourcestring[i].asSymbol});
16 time=0;
18 linetext= (
19 'a':[[[0,1],[0.5,0]],[[0.5,0],[1,1]],[[0.25,0.5],[0.75,0.5]]],
20 'b':[[[0,1],[0,0]],[[0,1],[1,1]],[[0,0],[1,0]],[[0,0.5],[0.75,0.5]],[[0.75,0.5],[1,0.75]],[[0.75,0.5],[1,0.25]],[[1,0.75],[1,1]],[[1,0.25],[1,0]]],
21 'c':[[[0,1],[0,0]],[[0,0],[1,0]],[[0,1],[1,1]]],
22 'd':[[[0,1],[0,0]],[[0,0],[0.75,0]],[[0,1],[0.75,1]],[[0.75,1],[1,0.75]],[[0.75,0],[1,0.25]],[[1,0.25],[1,0.75]]],
23 'e':[[[0,0],[0,1]],[[0,0],[1,0]],[[0,1],[1,1]],[[0,0.5],[1,0.5]]],
24 'f':[[[0,0],[0,1]],[[0,0],[1,0]],[[0,0.5],[1,0.5]]],
25 'g':[[[0,1],[0,0]],[[0,0],[1,0]],[[0,1],[1,1]],[[1,1],[1,0.5]],[[0.5,0.5],[1,0.5]]],
26 'h':[[[0,1],[0,0]],[[0,0.5],[1,0.5]],[[1,1],[1,0]]],
27 'i':[[[0,0],[1,0]],[[0.5,0],[0.5,1]],[[0,1],[1,1]]],
28 'j':[[[0,0],[1,0]],[[0.5,0],[0.5,1]],[[0,1],[0.5,1]]],
29 'k':[[[0,1],[0,0]],[[0,0.5],[1,1]],[[0,0.5],[1,0]]],
30 'l':[[[0,1],[0,0]],[[0,1],[1,1]]],
31 'm':[[[0,1],[0,0]],[[0,0],[0.5,0.5]],[[0.5,0.5],[1,0]],[[1,0],[1,1]]],
32 'n':[[[0,1],[0,0]],[[0,0],[1,1]],[[1,1],[1,0]]],
33 'o':[[[0,1],[0,0]],[[0,0],[1,0]],[[0,1],[1,1]],[[1,0],[1,1]]],
34 'p':[[[0,0],[0,1]],[[0,0],[1,0]],[[0,0.5],[1,0.5]],[[1,0],[1,0.5]]],
35 'q':[[[0,0],[0,0.75]],[[0,0],[0.75,0]],[[0,0.75],[0.75,0.75]],[[0.75,0],[0.75,0.75]],[[0.5,0.5],[1,1]]],
36 'r':[[[0,0],[0,1]],[[0,0],[1,0]],[[0,0.5],[1,0.5]],[[1,0],[1,0.5]],[[0,0.5],[1,1]]],
37 's':[[[0,0],[0,0.5]],[[0,0],[1,0]],[[0,1],[1,1]],[[0,0.5],[1,0.5]],[[1,0.5],[1,1]]],
38 't':[[[0,0],[1,0]],[[0.5,0],[0.5,1]]],
39 'u':[[[0,1],[0,0]],[[0,1],[1,1]],[[1,0],[1,1]]],
40 'v':[[[0,0],[0.5,1]],[[0.5,1],[1,0]]],
41 'w':[[[0,0],[0.25,1]],[[0.25,1],[0.5,0.5]],[[0.5,0.5],[0.75,1]],[[0.75,1],[1,0]]],
42 'x':[[[0,0],[1,1]],[[0,1],[1,0]]],
43 'y':[[[0,0],[0.5,0.5]],[[0.5,0.5],[1,0]],[[0.5,0.5],[0.5,1]]],
44 'z':[[[0,1],[1,0]],[[0,0],[1,0]],[[0,1],[1,1]]],
45 (" ".asSymbol):[[[0,1],[1,1]],[[0,0.8],[0,1]],[[1,0.8],[1,1]]]
48 w = Window("welcome", Rect(40, 500, h, v));
49 w.view.background = Color.blue(0.5);
50 w.onClose = { run = false };
51 w.front;
53 pen = Pen;
54 drawletter={arg which, startx, starty, xscale=100, yscale,prop=1.0;
55 var data;
57 yscale= yscale ? xscale;
59 data= linetext[which];
61 prop=(round((data.size)*prop).asInteger).max(1);
63 prop.do({arg i;
64 var val=data[i];
66 pen.beginPath;
67 pen.line(Point(startx+(xscale*val[0][0]),starty+(yscale*val[0][1])),Point(startx+(xscale*val[1][0]),starty+(yscale*val[1][1])));
68 pen.stroke;
70 });
75 yellowness=rrand(0.7,0.9);
77 penwidth=rrand(2,3);
79 w.drawHook = {
81         pen.use {var xoscil, xsizoscil,yoscil, todraw, usedtime;
83                 pen.width= penwidth;
84                 pen.color=Color.yellow(yellowness);
85                 
86                 usedtime=time.min(1.0);
87         
88                 todraw=(round((name.size)*usedtime).asInteger).max(1);
89                 
90                 todraw.do({arg j;
91                 
92                 xoscil= sin(2*pi*time+(j*pi*0.13))*140/(1+(10*time));
93                 
94                 yoscil= sin(2*pi*time+(j*pi*0.03))*200/(1+(200*time));
95                 
96                 xsizoscil= time*5+5;
97                 
98                 drawletter.value(name[j],50+(25*j)+(xoscil),10+yoscil,xsizoscil,xsizoscil,usedtime);
99                 
100                 });
101                 
102         };
103                 
104                 
107 { while { time<2.0 } { 
109 w.refresh;              
110 time=(time+0.025); //%2.0;
111 0.05.wait; } }.fork(AppClock)